<template>
  <div>
    <div class="mt20"></div>
    <div class="bor7 pa15">
      <el-row :gutter="20">
        <el-col :span="6" v-for="(neirong, d) in this.teamList" :key="d">
          <div class="grid-content bg-purple">
            <div class="activity pr">
              <div>
                <router-link
                  target="_blank"
                  :to="'/hotteamshow/' + neirong.activity_id"
                  class="bl over"
                  ><img :src="$api + neirong.image" class="w100" alt=""
                /></router-link>
                <div class="content">
                  <router-link
                    target="_blank"
                    :to="'/hotteamshow/' + neirong.activity_id"
                    class="bl name line2"
                    >{{ neirong.name }}
                  </router-link>
                  <div class="text line2" v-html="neirong.content"></div>
                  <div class="address text">
                    <i class="iconfont icon-renyuan"></i>成员人数:{{
                      neirong.join_num
                    }}
                  </div>
                  <el-popover placement="top" width="200" trigger="click"
                              :ref="'popover-' + neirong.activity_id"
                  >
                    <p>确认取消收藏？</p>
                    <div style="text-align: right; margin: 0">
                      <el-button
                        type="primary"
                        class="primary"
                        size="mini"
                        @click="unCollect('' + neirong.activity_id + '')"
                      >确定</el-button
                      >
                      <el-button
                        size="mini"
                        class="quxiao"
                        type="text"
                        @click="pCancel(neirong.activity_id)"
                      >取消</el-button
                      >
                    </div>
                    <el-button slot="reference"  type="primary quxiaosc">取消收藏</el-button>
                  </el-popover>
                </div>
              </div>
            </div>
          </div>
        </el-col>
      </el-row>
      <!-- 分页 -->
      <div class="block ta">
        <el-pagination
          layout="  prev, pager, next "
          :page-size="page_size"
          @current-change="current_change"
          :current-page.sync="currentPage"
          :pager-count="5"
          :total="info.total"
          v-if="info.pages > 1"
        >
        </el-pagination>
<el-empty description="暂无数据" v-if="info.total == 0"></el-empty>
      </div>
    </div>
  </div>
</template>


<script>
import { formatDate } from "../../assets/data.js";
export default {
  data() {
    return {
      activeName: "first",
      input: "",
      info: [],
      teamList: [],
      page_size: 8, //每页多少数据
      currentPage: 1, //默认当前页为第一页
      sort: "id",
    };
  },
  // 时间戳
  filters: {
    formatDate(time) {
      time = time * 1000;
      let date = new Date(time);
      return formatDate(date, "yyyy-MM-dd hh:mm:ss");
    },
  },
  methods: {
    pCancel(id) {
      this.$refs[`popover-`+id][0].doClose()
    },
    unCollect(team_id) {
      if(!team_id){
        this.$message.error('id不能为空');
        return false;
      }

      //定义一个json示例
      var jsons = {
        collect_id: team_id,
        collect_type: "team",
      };

      var that = this;

      this.$axios
        .post(this.$api + "/api/collect/delete", jsons)
        .then((res) => {
          //console.log(res.data);
          if (res.data.code == 1) {
            that.$message({
              message: res.data.msg,
              type: "success",
            });
            //location.reload();
            that.getteamList();
            that.pCancel(team_id)
          } else {
            that.$message.error(res.data.msg);
          }
        })
        .catch((Error) => {
          //console.log(Error);
        });
    },
    handleClick(tab, event) {
      //console.log(tab, event);
    },
    getteamList() {
      var that = this;
      this.$axios
        .get(
          this.$api +
            "//api/collect/index?page_no=" +
            that.currentPage +
            "&page_size=" +
            that.page_size +
            "&sort=" +
            that.sort +
            "&order=desc&search=collect_type:team;"
        )
        .then(function (response) {
          that.teamList = response.data.data.data;
          that.info = response.data.data.page;
          //console.log("团队收藏", that.teamList);
        })
        .catch(function (error) {
          //console.log(error);
        });
    },
  },
  mounted() {
    this.getteamList();
  },
};
</script>

<style scoped>
/* xiaoxi */
.quxiao {
      background: #f6f5f5;  font-size: 0.875rem;
          padding:0.3125rem 0.625rem;
}.quxiao:hover {
  background: #909399 !important;
  color: #fff !important;

}
.line2.text {
  height: 3.75rem;
  margin-top: 0.625rem;
}
html {
  height: 100% !important;
  overflow-y: hidden !important;
}
.el-tabs__content .el-tab-pane {
  background: #fff;
  padding: 1.25rem;
  border-radius: 0.4375rem;
}
.search-box {
  float: right;
}
.search .search-box form {
  float: left;
  border-radius: 4px;
  border: 1px solid #d8d8d8;
  width: 26.375rem;
  /* line-height: 2.5rem; */
}
.search .search-box form input {
  border: none;
  height: 100%;
  width: 70%;
  float: left;
  height: 2.5rem;
  border-radius: 4px;
  padding-left: 0.9375rem;
}
.search .search-box form input::-webkit-input-placeholder {
  color: rgba(84, 85, 86, 0.44);
}
.search .search-box form button {
  float: right;
}
.search .search-box .el-button {
  padding: 0.75rem 2rem;
}
.search .search-box > button {
  float: left;
  position: relative;
  top: 1px;
  margin-left: 0.9375rem;
}
.search {
  margin-bottom: 1.25rem;
}
.activity > div {
  border-radius: 0.625rem;
  border: solid 1px #dedede;
  overflow: hidden;
}
.activity .data {
  color: #848484;
}
.activity .content1 {
  padding: 1rem 0.8rem 1rem;
}
.activity .name {
  line-height: 1.25rem;
  font-weight: 600;
  color: #000000;
}

.activity .over {
  border-radius: 0.625rem 0.625rem 0px 0px;
}
.activity .people {
  line-height: 1.5rem;
  color: #848484;
  line-height: 3.125rem;
}
.activity .people .tx_img img {
  object-fit: cover;
  width: 3.125rem;
  height: 3.125rem;
  line-height: 3.125rem;
  border-radius: 50%;
  margin-right: 0.5rem;
  display: block;
}
.activity .people .fl div {
  float: left;
}
.mb30 {
  margin-bottom: 1.875rem;
}
.mb45 {
  margin-bottom: 2.8125rem;
}
.activity > div:hover {
  border-color: #de5044;
}
.activity > div:hover .over img {
  transform: scale(1.1);
}
.activity > div:hover .name {
  color: #de5044;
}
.activity-doxs .el-tabs__content .el-tab-pane {
  background: #fff;
  padding: 1.25rem;
  border-radius: 0.4375rem;
}
.activity-doxs > div {
  margin-bottom: 1.25rem;
}
.collect-box .iconfont {
  font: 0.875rem;
  color: #9f9fa0;
}
.collect-box .content1 p {
  /* margin-top: .5rem; */
  margin: 0.5rem 0;
}
.quxiaosc {
  position: absolute;
  top: .9375rem;
  right: .9375rem;
}@media (max-width:990px)  {
  .el-col-6 {
    width: 50% ;
    margin-bottom: 15px ;
  }
}
@media (max-width: 767px)  {
  .el-col-6 {
    width: 100% ;
    margin-bottom: 15px ;
  }
}
</style>
